import time
#在被装饰对象上正上方的单独一行写@装饰器名字
def timmer(func):
    def wrapper(*args,**kwargs):
        start=time.time()
        func(*args,**kwargs)
        stop=time.time()
        print(stop-start)
    return wrapper

@timmer#等同于index=timmer(index)
def index(x,y,z):
    time.sleep(3)
    print('index %s %s %s'%(x,y,z))
@timmer#home=timmer(home)
def home(name):
    print('welcome %s to home page'%name)

index(x=1,y=2,z=3)
home('Tom')

def auth(func):
    def wapper(*args,**kwargs):
        name=input('your name>>:').strip()
        pwd=input('your password>>:').strip()
        if name=='福旺' and pwd=='FW249746':
            res=func(*args,**kwargs)
            return res
        else:
            print('账号密码错误')
    return wapper

@auth#index=auth(index)
def index():
    print('from index')
index()#wrapper()




